package com.chzc.fm.duotin.ui.home;

import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.chzc.fm.duotin.R;
import com.chzc.fm.duotin.ui.other.BaseFragment;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/6/29.
 */
public class FragmentPlayListCount extends BaseFragment {



    @Override
    protected int getLayoutId() {
        return R.layout.fragment_pull_listview_count;
    }

    @Override
    protected void initViews() {

        //下载界面的listview
        final ListView listView = (ListView) root.findViewById(R.id.listView);
        //当没有数据时显示的默认视图
        listView.setEmptyView(root.findViewById(R.id.defaults_show));
        listView.setAdapter(new DownLoadAdapter());
       // listView.setOnItemClickListener(getContext());

    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected void initData() {

    }


    public class DownLoadAdapter extends BaseAdapter {

        private ArrayList<String> strings;

        public DownLoadAdapter() {

        }

        @Override
        public int getCount() {
            return strings==null?0:strings.size();
        }

        @Override
        public String getItem(int position) {
            return strings.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(getContext(), android.R.layout.simple_list_item_1, null);
            }
            TextView textView = (TextView) convertView;
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(Color.WHITE);
            ViewGroup.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
            textView.setLayoutParams(params);
            textView.setText(getItem(position));
            //  textView.setBackgroundColor(ColorUtil.generateBeautifulColor());
            return convertView;
        }
    }
}
